﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Text;

namespace DataDesign.MPP.Domain
{
    [Table(Name=GeneralTypeColumns.TABLE_NAME)]
    public class GeneralType:BaseDomain<GeneralType>,ICommonFunctions<GeneralType>
    {
        [Column(Name = GeneralTypeColumns.TYPE_ID, AutoSync = AutoSync.OnInsert, DbType = "Int NOT NULL IDENTITY", IsPrimaryKey = true, IsDbGenerated = true)]
        public int TypeID { get; set; }
        [Column(Name=GeneralTypeColumns.TYPE_VALUE)]
        public string TypeValue { get; set; }
        #region ICommonFunctions
        public GeneralType GetByPrimaryKey()
        {
            Table<GeneralType> table = GetTable();

            GeneralType item = table.Single(t => t.TypeID.Equals(this.TypeID));

            return item;

        }
        #endregion
        public static Dictionary<int, string> GetDictionary()
        {
            return GeneralType.GetAll().ToDictionary(row=>row.TypeID,row=>row.TypeValue);
        }
    }
}
